#NOTE: CMD includes subcommand
CMD="/c/local/bin/tool/AssetImporter.exe model"
ARGS="-t -l -split"

MODEL=$1

if [ "$MODEL" == "" ];then
	echo "Must refer to a model"
	exit
fi

ROOT_IMPORT="/d/War3Models"
ROOT_EXPORT="/c/Projects/legend/resource/3d/Data/Models/War3"

# 幻影刺客
if [ "$MODEL" == "Maiev" ]; then
	echo "===Maiev==="
	MODEL_PATH="Units/NightElf/Maiev"
	mkdir -p $ROOT_EXPORT/$MODEL_PATH
	# 999~1400
	$CMD $ROOT_IMPORT/$MODEL_PATH/Maiev_Stand-1.FBX $ROOT_EXPORT/$MODEL_PATH/Maiev_Stand-1.mdl $ARGS 3.33 4.67
	# 8000~8349
	$CMD $ROOT_IMPORT/$MODEL_PATH/Maiev_Walk.FBX $ROOT_EXPORT/$MODEL_PATH/Maiev_Walk.mdl $ARGS 26.67 27.83
	# 9090~9390
	$CMD $ROOT_IMPORT/$MODEL_PATH/Maiev_Death.FBX $ROOT_EXPORT/$MODEL_PATH/Maiev_Death.mdl $ARGS 30.30 31.30
	# 11439~11799
	$CMD $ROOT_IMPORT/$MODEL_PATH/Maiev_SpellSlam.FBX $ROOT_EXPORT/$MODEL_PATH/Maiev_SpellSlam.mdl $ARGS 38.13 39.33
	# 14000~14289
	$CMD $ROOT_IMPORT/$MODEL_PATH/Maiev_Attack-1.FBX $ROOT_EXPORT/$MODEL_PATH/Maiev_Attack-1.mdl $ARGS 46.67 47.63
fi

if [ "$MODEL" == "VillagerWoman" ]; then
	echo "===VillagerWoman==="
	MODEL_PATH="units/Critters/VillagerWoman"
	mkdir -p $ROOT_EXPORT/$MODEL_PATH
	# 450~900
	$CMD $ROOT_IMPORT/$MODEL_PATH/VillagerWoman_Stand-1.FBX $ROOT_EXPORT/$MODEL_PATH/VillagerWoman_Stand-1.mdl $ARGS 1.5 3.0
fi

# 水晶室女
if [ "$MODEL" == "Jaina" ]; then
	echo "===Jaina==="
	MODEL_PATH="units/Human/Jaina"
	mkdir -p $ROOT_EXPORT/$MODEL_PATH
	$CMD $ROOT_IMPORT/$MODEL_PATH/Jaina_Stand.FBX $ROOT_EXPORT/$MODEL_PATH/Jaina_Stand.mdl $ARGS 3.33 4.664
	$CMD $ROOT_IMPORT/$MODEL_PATH/Jaina_Attack.FBX $ROOT_EXPORT/$MODEL_PATH/Jaina_Attack.mdl $ARGS 17.33 18.73
	$CMD $ROOT_IMPORT/$MODEL_PATH/Jaina_Spell.FBX $ROOT_EXPORT/$MODEL_PATH/Jaina_Spell.mdl $ARGS 19.9 22.63
	$CMD $ROOT_IMPORT/$MODEL_PATH/Jaina_Walk.FBX $ROOT_EXPORT/$MODEL_PATH/Jaina_Walk.mdl $ARGS 41.13 43.13
	$CMD $ROOT_IMPORT/$MODEL_PATH/Jaina_Death.FBX $ROOT_EXPORT/$MODEL_PATH/Jaina_Death.mdl $ARGS 45.167 48.667
fi

# 兽族步兵
if [ "$MODEL" == "Grunt" ]; then
	echo "===Grunt==="
	MODEL_PATH="units/Orc/Grunt"
	mkdir -p $ROOT_EXPORT/$MODEL_PATH
	$CMD $ROOT_IMPORT/$MODEL_PATH/Grunt_Walk.FBX $ROOT_EXPORT/$MODEL_PATH/Grunt_Walk.mdl $ARGS 0.667 1.33
	$CMD $ROOT_IMPORT/$MODEL_PATH/Grunt_Stand.FBX $ROOT_EXPORT/$MODEL_PATH/Grunt_Stand.mdl $ARGS 1.83 4.83
	$CMD $ROOT_IMPORT/$MODEL_PATH/Grunt_Attack.FBX $ROOT_EXPORT/$MODEL_PATH/Grunt_Attack.mdl $ARGS 5.13 6.10
	$CMD $ROOT_IMPORT/$MODEL_PATH/Grunt_Death.FBX $ROOT_EXPORT/$MODEL_PATH/Grunt_Death.mdl $ARGS 6.83 8.4
	$CMD $ROOT_IMPORT/$MODEL_PATH/Grunt_Spell.FBX $ROOT_EXPORT/$MODEL_PATH/Grunt_Spell.mdl $ARGS 87.73 89.167
fi

# 卡尔
if [ "$MODEL" == "Kael" ]; then
	echo "===Kael==="
	MODEL_PATH="units/Human/Kael"
	mkdir -p $ROOT_EXPORT/$MODEL_PATH
	$CMD $ROOT_IMPORT/$MODEL_PATH/${MODEL}_Stand.FBX $ROOT_EXPORT/$MODEL_PATH/${MODEL}_Stand.mdl $ARGS 1.5 3.0
	$CMD $ROOT_IMPORT/$MODEL_PATH/${MODEL}_Attack.FBX $ROOT_EXPORT/$MODEL_PATH/${MODEL}_Attack.mdl $ARGS 20 21.5
	$CMD $ROOT_IMPORT/$MODEL_PATH/${MODEL}_Spell.FBX $ROOT_EXPORT/$MODEL_PATH/${MODEL}_Spell.mdl $ARGS 26.667 28.167
	$CMD $ROOT_IMPORT/$MODEL_PATH/${MODEL}_Walk.FBX $ROOT_EXPORT/$MODEL_PATH/${MODEL}_Walk.mdl $ARGS 9.667 10.60
	$CMD $ROOT_IMPORT/$MODEL_PATH/${MODEL}_Death.FBX $ROOT_EXPORT/$MODEL_PATH/${MODEL}_Death.mdl $ARGS 40 43
fi

# 剑圣
if [ "$MODEL" == "HeroBladeMaster" ]; then
	echo "===HeroBladeMaster==="
	MODEL_PATH="units/Orc/${MODEL}"
	mkdir -p $ROOT_EXPORT/$MODEL_PATH
	$CMD $ROOT_IMPORT/$MODEL_PATH/${MODEL}_Attack.FBX $ROOT_EXPORT/$MODEL_PATH/${MODEL}_Attack.mdl $ARGS 14.33 15.50
	$CMD $ROOT_IMPORT/$MODEL_PATH/${MODEL}_Stand-4.FBX $ROOT_EXPORT/$MODEL_PATH/${MODEL}_Spell.mdl $ARGS 18.33 19.867
	$CMD $ROOT_IMPORT/$MODEL_PATH/${MODEL}_Death.FBX $ROOT_EXPORT/$MODEL_PATH/${MODEL}_Death.mdl $ARGS 22.00 23.90
	$CMD $ROOT_IMPORT/$MODEL_PATH/${MODEL}_Walk.FBX $ROOT_EXPORT/$MODEL_PATH/${MODEL}_Walk.mdl $ARGS 28.767 29.50
	$CMD $ROOT_IMPORT/$MODEL_PATH/${MODEL}_Stand.FBX $ROOT_EXPORT/$MODEL_PATH/${MODEL}_Stand.mdl $ARGS 30.50 31.667
fi
